from tortoise.models import Model
from tortoise import fields


#创建部门类
class Department(Model):
    id = fields.IntField(pk=True, auto_increment=True)
    depart_name = fields.CharField(max_length=255, description="部门名称")
    depart_hobby = fields.CharField(max_length=255,
                                    description="部门爱好",
                                    null=True)


class Employee(Model):
    id = fields.IntField(pk=True, auto_increment=True)
    name = fields.CharField(max_length=255, description="员工姓名")
    hobby = fields.CharField(max_length=255, description="员工爱好", null=True)
    department = fields.ForeignKeyField('models.Department',
                                        related_name='employee')  #外链部门
    #related_name表示反向引用，


class Bug_Info(Model):
    id = fields.IntField(pk=True, auto_increment=True)
    bug_name = fields.CharField(max_length=255, description="bug名称")
    bug_desc = fields.CharField(max_length=255, description="bug描述", null=True)
    bug_creator = fields.CharField(max_length=255, description="bug创建者")
    bug_assignee = fields.CharField(max_length=255, description="bug指派人")
    #指向test_depart，标识一个测试部门可以有多个相关bug
    depart = fields.ForeignKeyField('models.Department',
                                    related_name='bugs_info')

class User_Register(Model):
    id=fields.IntField(pk=True,auto_increment=True)
    username=fields.CharField(max_length=255,description="用户名")
    password=fields.CharField(max_length=255,description="密码")
